package com.qipay.admin.mapper;

import com.qipay.baas.mapper.CpSqlProvider;
import com.qipay.baas.model.ChannelType;
import com.qipay.baas.model.Cp;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

public interface ChannelTypeMapper extends com.qipay.baas.mapper.ChannelTypeMapper{
//    @Delete({
//        "delete from cp",
//        "where id = #{id,jdbcType=BIGINT}"
//    })
//    int deleteByPrimaryKey(Long id);
//
//    @Insert({
//        "insert into cp (`type`, app_id, ",
//        "secret_id, agent_id, fee_default_recharge, ",
//        "cost_withdraw, fee_withdraw_advince, ",
//        "withdraw_password, notify_url, ",
//        "ip, bind_mobile, ",
//        "create_time, account_state, ",
//        "contract_state)",
//        "values (#{type,jdbcType=TINYINT}, #{appId,jdbcType=CHAR}, ",
//        "#{secretId,jdbcType=CHAR}, #{agentId,jdbcType=BIGINT}, #{feeDefaultRecharge,jdbcType=DECIMAL}, ",
//        "#{costWithdraw,jdbcType=INTEGER}, #{feeWithdrawAdvince,jdbcType=DECIMAL}, ",
//        "#{withdrawPassword,jdbcType=VARCHAR}, #{notifyUrl,jdbcType=VARCHAR}, ",
//        "#{ip,jdbcType=VARCHAR}, #{bindMobile,jdbcType=VARCHAR}, ",
//        "#{createTime,jdbcType=TIMESTAMP}, #{accountState,jdbcType=TINYINT}, ",
//        "#{contractState,jdbcType=TINYINT})"
//    })
//    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
//    int insert(Cp record);


    @Select({
        "select",
        "id, `name`, cp_fee_recharge, agent_fee_recharge",
        "from channel_type"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="cp_fee_recharge", property="cpFeeRecharge", jdbcType=JdbcType.DECIMAL),
        @Result(column="agent_fee_recharge", property="agentFeeRecharge", jdbcType=JdbcType.DECIMAL)
    })
    List<ChannelType> selectAll();

    @Update({
        "update channel_type",
        "set `id` = #{id,jdbcType=BIGINT},",
          "name = #{name,jdbcType=VARCHAR},",
          "cp_fee_recharge = #{cpFeeRecharge,jdbcType=DECIMAL},",
          "agent_fee_recharge = #{agentFeeRecharge,jdbcType=DECIMAL}"
    })
    int update(ChannelType record);
}